package com.hyperfix.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hyperfix.models.user.dtos.UserInfoDTO;
import com.hyperfix.models.user.pojos.UserInfo;
import com.hyperfix.models.user.vos.UserInfoQueryVO;
import com.hyperfix.models.user.vos.UserInfoVO;
import org.apache.ibatis.annotations.*;

/**
 * @author JiangChunYu
 * 2024/4/7
 */
@Mapper
public interface UserInfoMapper extends BaseMapper<UserInfo> {
    @Delete("delete from user_info where user_id = (select id from user where username = #{username})")
    boolean deleteUserInfoByUsername(@Param("username") String username);

    UserInfoDTO selectUserInfoByUsername(@Param("username") String username);

    @Update("update user_info set name = #{name}, age = #{age}, sex = #{sex}, birthday = #{birthday}, phone = #{phone}, email = #{email} where user_id = (select id from user where username = #{username})")
    boolean updateInfo(UserInfoVO userInfoVO);

    IPage<UserInfoDTO> listUserInfoDTO(IPage<UserInfoDTO> page, @Param("params") UserInfoQueryVO userInfoQueryVO);
}
